<script lang="ts" setup>
//标题
import Share from "./Share.vue";
import { ElTooltip } from "element-plus";

import { computed } from "vue";
import { IndexShowData } from "@/api/interface";
export interface Props {
  data: IndexShowData;
}

//接收数据
const props = defineProps<Props>();

//不超过26个字，则使用居中
const active = computed(() => {
  if (props.data && props.data.title) {
    return props.data.title.length > 27 ? "article-header" : "featured-header";
  } else {
    return "";
  }
});

//核心内容
</script>

<template>
  <div :class="active" v-if="data">
    <!--分类和时间-->
    <div class="category component">
      <div class="component-content">
        <div class="category-eyebrow">
          <span class="category-eyebrow__category">
            <el-tooltip
              class="box-item"
              effect="dark"
              content="查看分类信息"
              placement="right"
            >
              <span>
                <router-link
                  :to="`/category/${item.id}`"
                  :key="item.id"
                  v-for="item in data.cat"
                >
                  {{ item.name }}
                </router-link>
              </span>
            </el-tooltip>
          </span>

          <span class="category-eyebrow__date"> {{ data.date }}</span>
        </div>
      </div>
    </div>
    <!--标题-->
    <div class="pagetitle component">
      <div class="component-content">
        <h1 class="hero-headline">
          {{ data.title }}
        </h1>
      </div>
    </div>
    <!--副标题-->
    <div class="article-subhead component">
      <div class="component-content">
        <div v-html="data.excerpt"></div>
      </div>
    </div>
    <!--社交分享-->
    <div class="sharesheet component">
      <div class="component-content">
        <Share :postData="data"></Share>
      </div>
    </div>
  </div>
  <div v-else>
    <el-skeleton animated :throttle="500">
      <template #template>
        <div :class="active">
          <!--分类和时间-->
          <div class="category component">
            <div class="component-content">
              <div class="category-eyebrow">
                <span class="category-eyebrow__category">
                  <el-skeleton-item variant="text" style="width: 15%" />
                  &nbsp;·&nbsp;
                  <el-skeleton-item variant="text" style="width: 35%" />
                </span>
              </div>
            </div>
          </div>
          <!--标题-->
          <div class="pagetitle component">
            <div class="component-content">
              <h1 class="hero-headline">
                <el-skeleton-item variant="h1" style="width: 100%" />
              </h1>
            </div>
          </div>
          <!--副标题-->
          <div class="article-subhead component">
            <div class="component-content">
              <el-skeleton-item variant="h3" style="width: 50%" />
            </div>
          </div>
          <!--社交分享-->
          <div class="sharesheet component">
            <div class="component-content">
              <el-skeleton-item variant="h3" style="width: 35%" />
            </div>
          </div>
        </div>
      </template>
    </el-skeleton>
  </div>
</template>

<style lang="less" scoped>
.category.component {
  margin-top: 0;
  margin-bottom: 20px;
}

.category-eyebrow {
  font-size: 12px;
  line-height: 1.33337;
  font-weight: 700;
  letter-spacing: 0em;
  font-family: "SF Pro Text", "SF Pro Icons", "Helvetica Neue", "Helvetica",
    "Arial", sans-serif;
}

.category-eyebrow__category {
  text-transform: uppercase;
  color: #6e6e73;
  border-color: #6e6e73;
  a {
    margin-right: 10px;
    color: inherit;
    font-weight: inherit;
  }
}
.category-eyebrow__category,
.category-eyebrow__date {
  display: block;
}

.category-eyebrow__date {
  font-size: 14px;
  line-height: 1.28577;
  font-weight: 600;

  font-family: @font-family-main;
  letter-spacing: 0em;
  margin-top: 4px;
  color: @font-color-assist;
}

//标题
.pagetitle.component {
  margin-top: 0;
  margin-bottom: 0;
}
.hero-headline {
  font-size: 48px;
  line-height: 1.08349;
  font-weight: 700;
  //letter-spacing: -.003em;
  letter-spacing: 0em;
  font-family: "SF Pro SC", "SF Pro Display", "SF Pro Icons", "PingFang SC",
    "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
//副标题
.article-subhead {
  font-size: 24px;
  line-height: 1.16667;
  font-weight: 500;
  letter-spacing: 0.009em;
  font-family: "SF Pro SC", sans-serif;
  margin-top: 20px;
  margin-bottom: 0;
}

.sharesheet {
  margin-bottom: 0;
  margin-top: 24px;
}

//-------------------------------------------//
//居中样式
.featured-header {
  .category-eyebrow {
    display: flex;
    justify-content: center;
    margin-top: 16px;
  }
  .category-eyebrow__category,
  .category-eyebrow__date {
    color: #6e6e73;
    margin: 4px 0;
  }
  .category-eyebrow__category {
    display: flex;
    align-items: center;
  }
  .category-eyebrow__category::after {
    color: #6e6e73;
    content: "\2022";
    margin: 0 8px;
  }
  .pagetitle {
    .component-content {
      width: 83.33333%;
    }
  }

  .article-subhead {
    text-align: center;
  }
  .sharesheet {
    text-align: center;
    margin-top: 24px;
    margin-bottom: 0;
  }
}
//标题
.hero-headline {
  font-size: 56px;
  line-height: 1.07143;
  font-weight: 700;
  letter-spacing: 0em;
  font-family: "SF Pro SC", "SF Pro Display", "SF Pro Icons", "PingFang SC",
    "Helvetica Neue", "Helvetica", "Arial", sans-serif;
  text-align: center;
}
//副标题

@media only screen and (max-width: 1068px) {
  .pagetitle {
    .hero-headline {
      font-size: 48px;
      line-height: 1.1;
      font-weight: 700;
    }
  }

  .article-subhead {
    font-size: 21px;
    line-height: 1.19048;
    font-weight: 500;
    letter-spacing: 0.011em;
  }
}
@media only screen and (max-width: 734px) {
  .category-eyebrow {
    margin-top: 20px;
  }
  .pagetitle {
    .component-content {
      margin-left: auto;
      margin-right: auto;
      width: 87.5%;
    }
    .hero-headline {
      font-size: 32px;
      line-height: 1.125;
      font-weight: 700;
    }
  }
  .sharesheet {
    margin-top: 20px;
  }
}
</style>
